package com.haitonghop.modules.tamdiem;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.haitonghop.R;
import com.haitonghop.utils.Logger;

@SuppressLint("SetJavaScriptEnabled")
public class TamDiemCommentActivity extends Activity{

	WebView webView;
	LinearLayout loadingProcess;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		Bundle extras = getIntent().getExtras();
		String value = "";
		if (extras != null) {
		    value = extras.getString("IMAGE_ID");
		    Logger.logMe("value = "+value);
		}

		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.haivl_activity_comment_layout);

		webView = (WebView)findViewById(R.id.webViewComment);
		loadingProcess = (LinearLayout)findViewById(R.id.loadingProcessComment);
		loadingProcess.setVisibility(View.VISIBLE);

		String url = "https://www.facebook.com/plugins/comments.php?api_key=267956709937854&locale=en_US&sdk=joey&" +
				"channel_url=http://static.ak.facebook.com/connect/xd_arbiter.php?version=18&cb=f33232cf6&" +
				"origin=http://www.tamdiem.net/fbc898008&domain=www.tamdiem.net&relation=parent.parent&numposts=4&width=620&" +
				"href="+value;

		if(webView != null){
			webView.setVisibility(View.INVISIBLE);
			webView.loadUrl(url);
			webView.setPadding(0, 0, 0, 0);
			webView.setInitialScale(100);
			webView.getSettings().setJavaScriptEnabled(true);
			webView.setWebViewClient(chromeClient);
		}

//		TextView textView = (TextView)findViewById(R.id.titleActivity);
//		textView.setText("Bình luận");
//
//		Button moreFunction = (Button)findViewById(R.id.btnMoreFunctions);
//		if(moreFunction != null){
//			moreFunction.setVisibility(View.GONE);
//		}
	}

	WebViewClient chromeClient = new WebViewClient(){

		@Override
		public void onPageFinished(WebView view, String url) {
			loadingProcess.setVisibility(View.GONE);
			webView.setVisibility(View.VISIBLE);
		};
	};
}
